import 'package:chatroom_flutter_app/ui/widget/setting_item.dart';
import 'package:chatroom_flutter_app/util/my_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

// SingleChildScrollView 单个 scrollview 简单的逻辑地方可以使用，
// 并无优化
// https://www.likecs.com/show-204655367.html



class MinePage extends StatefulWidget {
  const MinePage({Key? key}) : super(key: key);

  @override
  State<MinePage> createState() => _MinePageState();
}

class _MinePageState extends State<MinePage> {

  onTap(index){
    //print(index);
    switch(index){
      case 0:
        break;
      case 1:
        break;
      case 2:
        break;
      default:
        break;
    }

  }
  
  Widget getServiceItemBlock(assetsUri,title){
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Image.asset(assetsUri),
        SizedBox(height: 2.r),
        Text(title,style: TextStyle(fontSize: 12.sp,color: const Color(0xff333333)))
      ],
    );
  }

  Widget getMoneyItemBlock(title,assetsPath,val){
    return Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text(val,style: TextStyle(fontSize: 18.sp,color: MyColors.black22)),
        SizedBox(height: 10.r),
        Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            SizedBox(
              child: Image.asset(assetsPath),
            ),
            SizedBox(width: 3.r),
            Text(title,style: TextStyle(color: const Color(0xff9F9CB0),fontSize: 11.sp))
          ],
        )
      ],
    );
  }

  Widget getLine(){
    return Container(
      width:  .4.r,
      height: 23.r,
      color: const Color(0xffe8e8e8),
    );
  }

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: ScreenUtil().screenWidth,
      height: ScreenUtil().screenHeight,
      child: SafeArea(
        child: SingleChildScrollView(
          child: Column(
            children:  <Widget>[
              Container(
                color: Colors.white,
                child: Column(
                  children: [
                    Padding(padding: EdgeInsets.only(top:24.r,left: 23.r,right: 23.r),child:  Row(
                      children: [
                        Stack(
                          alignment: Alignment.center,
                          children: [
                            SizedBox(
                              width: 65.r,
                              height: 65.r,
                              child: ClipRRect(
                                borderRadius: BorderRadiusDirectional.circular(65.r),
                                child: Image.network('https://ucavatar.tuwan.com/data/avatar/003/84/41/13_avatar_middle.jpg?random=20230314'),
                              ),
                            ),
                            Positioned(
                              bottom: 0,
                              child:  Container(
                                height: 16.r,
                                width: 40.r,
                                decoration: BoxDecoration(
                                    borderRadius: BorderRadius.circular(6.r),
                                    color: Colors.blueAccent
                                ),
                                child: Text('编辑',style: TextStyle(color: Colors.white,fontSize: 11.sp,height: 16.r),textAlign: TextAlign.center),
                              ),)
                          ],
                        ),
                        Expanded(
                          child: Padding(
                            padding: EdgeInsets.only(left: 8.r),
                            child: Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children:  [
                                Row(
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children:[
                                    Text('李狗蛋❀', style: TextStyle(color: MyColors.black22,fontSize: 20.sp)),
                                    SizedBox(width: 8.r),
                                    SizedBox(height: 15.r, child: Image.network('https://res.tuwan.com/templet/play/public/images/0.png'))
                                  ],
                                ),
                                SizedBox(height: 2.r),
                                Text('UID:3844140',style: TextStyle(color: const Color(0xff999999),fontSize: 11.sp)),
                              ],
                            ),
                          ),
                        ),
                        SizedBox(
                            width: 20.r,
                            height: 20.r,
                            child: Image.asset('./assets/images/icon_more.png')
                        )
                      ],
                    )),
                    Padding(padding: EdgeInsets.only(top:28.r,bottom: 10.r,left: 36.r,right: 36.r),child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          getMoneyItemBlock('钻石','./assets/images/icon_mine_diamond.png','0'),
                          getLine(),
                          getMoneyItemBlock('金币','./assets/images/icon_mine_coin.png','0'),
                          getLine(),
                          getMoneyItemBlock('点点币','./assets/images/icon_mine_money.png','0.00'),
                        ]
                    ),)
                  ],
                ),
              ),
              SizedBox(height: 8.r),
              Container(
                decoration: const BoxDecoration(
                  color: Colors.white
                ),
                child: Column(
                  children: [
                    Padding(
                      padding: EdgeInsets.fromLTRB(24.r, 8.r, 24.r, 9.r),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text('我的服务',style: TextStyle(
                              fontSize: 14.sp,
                              color: MyColors.black22
                          ),),
                          SizedBox(
                              width: 20.r,
                              height: 20.r,
                              child: Image.asset('./assets/images/icon_more.png')
                          )
                        ],
                      ),
                    ),
                    Padding(padding: EdgeInsets.fromLTRB(40.r, 9.r, 40.r, 12.r),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          getServiceItemBlock('./assets/images/icon_mine_captain.png','队长认证'),
                          getServiceItemBlock('./assets/images/icon_mine_rank.png','队长积分排行'),
                          getServiceItemBlock('./assets/images/icon_mine_withdraw.png','提现'),
                        ],
                      ),)
                  ],
                ),
              ),
              SizedBox(height: 8.r),
              SettingItem(0, './assets/images/icon_setting_set.png', '个性装扮',onTap),
              SettingItem(1, './assets/images/icon_setting_set.png', '关注管理',onTap),
              SettingItem(2, './assets/images/icon_setting_set.png', '填写邀请码',onTap),
              SettingItem(3, './assets/images/icon_setting_game.png', '绑定游戏',onTap),
              SettingItem(4, './assets/images/icon_setting_service.png', '联系客服',onTap),
              SettingItem(5, './assets/images/icon_setting_set.png', '未成年人专属客服',onTap),
              SettingItem(6, './assets/images/icon_setting_set.png', '帮助与反馈',onTap),
              SettingItem(7, './assets/images/icon_setting_set.png', '设置',onTap),

            ]
          )
        ),
      ),


    );
  }
}
